﻿@using System.Web.UI.WebControls
@using DevExpress.Web.Mvc.UI
@using Dogshow.Web.ViewModels.Izlozbe
@model RasePoRingovimaViewModel


@Html.DevExpress().GridView(s =>
{
    s.Name = "gvRaseURingu";
    s.Caption = "Rase pasa";
    s.CallbackRouteValues = new {Controller = "Izlozbe", Action = "RaseURinguGridViewCallback"};
    s.Columns.Add(c =>
    {
        c.FieldName = "IdRase";
        c.Caption = "Naziv rase";
        c.CellStyle.HorizontalAlign = HorizontalAlign.Left;
        c.SetDataItemTemplateContent((ct) => ViewContext.Writer.WriteLine(DataBinder.Eval(ct.DataItem, "NazivRase")));
        c.SetEditItemTemplateContent(t => @Html.RenderPartial("_RasaPsaComboBox", new ViewDataDictionary(DataBinder.Eval(t.DataItem, "IdRase"))));
        
    });
    s.SettingsPager.PageSize = 25;
    s.Width = Unit.Pixel(300);
    s.KeyFieldName = "IdRase";
    s.SettingsBehavior.ConfirmDelete = true;
    s.SettingsText.ConfirmDelete = "Da li ste sigurni da želite da obrišete rasu?";
    s.SettingsText.EmptyDataRow = "Nema podataka";
    
    s.CommandColumn.Visible = true;
    s.CommandColumn.ButtonType = ButtonType.Image;
    s.CommandColumn.DeleteButton.Visible = true;
    s.CommandColumn.DeleteButton.Image.ToolTip = "Obriši";
    s.CommandColumn.DeleteButton.Image.Url = @Url.Content("~/Content/images/user_trash.png");
    s.SettingsEditing.DeleteRowRouteValues = new {Controller = "Izlozbe", Action = "ObrisiRasuIzRinga" };

    s.SettingsEditing.AddNewRowRouteValues = new {Controller = "Izlozbe", Action = "DodajRasuURing", Model.IdIzlozbe, Model.IdSudije};
    
    s.CommandColumn.UpdateButton.Image.ToolTip = "Prihvati";
    s.CommandColumn.UpdateButton.Image.Url = @Url.Content("~/Content/images/ok.png");
    s.CommandColumn.CancelButton.Image.ToolTip = "Otkaži";
    s.CommandColumn.CancelButton.Image.Url = @Url.Content("~/Content/images/cancel.png");
    s.CommandColumn.SetHeaderTemplateContent(c => @Html.DevExpress().HyperLink(link =>
    {
        link.Name = "btnDodajRasu";
        link.Properties.Text = "Dodaj rasu";
        link.Properties.ClientSideEvents.Click = "btnDodajRasuClick";
    }).GetHtml());
    
    s.ClientSideEvents.BeginCallback = "onBeginCallback_gvRaseURingu";
}).Bind(Model.RaseURingu).GetHtml()
      